package Thread.thread;

import java.util.concurrent.Callable;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.FutureTask;

/**
 * @author 23050
 * @version 1.0
 * @description: TODO
 * @date 2024/2/29 21:42
 */
public class MyCallable implements Callable<String> {
    @Override
    public String call() throws Exception {
        System.out.println("实现Callable接口");
        return "Callable";
    }

    public static void main(String[] args) throws ExecutionException, InterruptedException {
        MyCallable mc = new MyCallable();
        FutureTask<String> futureTask = new FutureTask<String>(mc);
        Thread t1 = new Thread(futureTask);
        t1.start();
        String result = futureTask.get();
        System.out.println(result);

    }


}
